package gui.menu;



import gui.IHM;

import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;

import tuio.components.ButtonTouch;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class MenuPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8475751505006519027L;
	
	private static final Dimension dimButton = new Dimension(60,20);
	
	private static final Insets insetsButton = new Insets(0, 0, 0, 0);
	
	public MenuPanel(final IHM ihm){
		setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
	
		ButtonTouch exit = new ButtonTouch("Exit");
		exit.setMargin(insetsButton);
		exit.setPreferredSize(dimButton);
		
		exit.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				try {
					ihm.getTimeControl().closeSocket();
				} catch (IOException e1) {
					e1.printStackTrace();
				}
				System.exit(0);
			}
		});
		
		ButtonTouch openFile = new ButtonTouch("Open");
		openFile.setMargin(insetsButton);
		openFile.setPreferredSize(dimButton);
		
		
		add(exit);
		add(Box.createRigidArea(new Dimension(10,0)));
		add(openFile);
		add(Box.createHorizontalGlue());
	}

}
